<?php

namespace App\Http\Controllers;

use App\Models\Message;
use Illuminate\Http\Request;

class MessageController extends BaseController
{
    public function index(Request $request)
    {
        $param = $this->validate($request,[
            'type' => 'required|in:1,2,3,4,5,6,7'
        ]);

        $message  = Message::query()->where($param)->orderByDesc('id')->limit(20)->get();

        return $this->success($message);
    }

    public function show(Request $request)
    {
        $param = $this->validate($request,[
            'id' => 'required|integer'
        ]);

        $message  = Message::query()->where($param)->first();

        return $this->success($message);

    }
}
